# Contributor: goodspb <goodspb.luo@gmail.com>
# Maintainer: Adriaan Groenenboom <agboom@pm.me>
pkgname=php7-pdlib
_extname=pdlib
pkgver=1.0.2
pkgrel=1
pkgdesc="PHP 7 extension for Dlib"
url="https://github.com/goodspb/pdlib"
arch="all !ppc64le" # build fails https://github.com/goodspb/pdlib/issues/19
license="MIT"
depends="php7-common dlib"
makedepends="php7-dev pkgconf php7-bz2"
source="php-$_extname-$pkgver.tar.gz::https://github.com/goodspb/$_extname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_extname-$pkgver"

#disable check on s390x as Frontal face detection failling
[ "$CARCH" = "s390x" ] && options="!check"

build() {
	phpize7
	./configure --prefix=/usr --with-php-config=php-config7
	make
}

check() {
	# Tests require bz2 extension which is not bundled
	local _modules=/usr/lib/php7/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		TESTS=--show-diff SKIP_ONLINE_TESTS=1 \
		PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=$_modules/bz2.so \
		-d extension=modules/$_extname.so"
	php7 -dextension=modules/$_extname.so --ri $_extname
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/php7/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/$_extname.ini
}

sha512sums="7222eeaedad8bfe8d0deb327c4d1deaea172994cfb2f2d43fb10f6b862ccc56e05bb459e0d2c94ed79f222eed8eb7c1974c15f862549bf563b132b531acf1cd3  php-pdlib-1.0.2.tar.gz"
